下·<template>
  <lb-table
    ref="lbTable"
    border
    height="70vh"
    highlight-current-row
    element-loading-text="加载中"
    :column="tableData.column"
    :data="tableData.data"
    pagination
    :total="tableData.total"
    append-to-body
    @fetch="getData"
  />
</template>

<script>
  import { parseTime } from '@/utils'
  import { customerCsmInsure } from '@/api'
  export default {
    name: 'tab-insurance',
    props: ['csmId'],
    data() {
      return {
        tableData: {
          column: [
            {
              prop: 'insureCode',
              label: '投保单号',
              width: 100
            },
            {
              prop: 'csmAddress',
              label: '单位地址',
              width: 200
            },
            {
              prop: 'ckOrgName',
              label: '所属机构',
              width: 170
            },
            {
              prop: 'insureAcc',
              label: '投保金额',
              align: 'right'
            },
            {
              prop: 'insureStartDt',
              label: '投保开始时间',
              width: 120,
              render: (h, { row }) => <span>{ row.insureStartDt && parseTime(row.insureStartDt, '{y}-{m}-{d}') }</span>
            },
            {
              prop: 'insureEndDt',
              label: '投保结束时间',
              width: 120,
              render: (h, { row }) => <span>{ row.insureEndDt && parseTime(row.insureEndDt, '{y}-{m}-{d}') }</span>
            },
            {
              prop: 'salePersonName',
              label: '售保员'
            },
            {
              prop: 'remark',
              label: '备注'
            }
          ],
          data: []
        }
      }
    },
    methods: {
      async getData({ currentPage = 1, pageSize = 20 }) {
        const params = {
          currentPage,
          pageSize,
          csmId: this.csmId
        }
        const res = await customerCsmInsure(params)
        this.tableData.data = res.data.rows
        if (currentPage === 1) this.tableData.total = res.data.total
      }
    }
  }
</script>

<style lang="scss" scoped>
  .table {
    min-height: 80vh;
  }
</style>
